<?php

include('header.php');
include('menu.php');
error_reporting(E_ALL || E_STRICT);
include('Paging_inbox/paginator.class.php');
include("connection/connection.php");
$loginid=$_SESSION['loginid'];

//$conn = new mysqli('localhost', 'ramky123_phed', '7B4x[wd3V#A7','ramky123_phed') ;
$query2="select * from tbl_dtls_compose where status='1' and receiver in('$loginid')";
$result2=mysql_query($query2);
$no_of_record1=mysql_num_rows($result2); 
/*
if($_SERVER['HTTP_HOST']=="www.zioninformatics.com"||$_SERVER['HTTP_HOST']=="zioninformatics.com")
{
	$conn = new mysqli('localhost', 'samir696_phed', '1q2w3e4r5t6y','samir696_phed') ;
}
else
{
	$conn = new mysqli('localhost', 'root', '','ramky123_phed') ;
}*/

$conn = mysqli_connection_str();
//the above connection is created and above content is commented by rama krishna on 08-march-2015
$query="select * from tbl_dtls_compose where receiver in('$loginid')";
$result=mysql_query($query);
$no_of_record=mysql_num_rows($result); 
$recordsPerPage = 50;
if(!empty($_GET['search'])){
	$searchQuery = $_GET['search'];
}

$pageId= intval($_GET['page']);
if (empty($pageId)) {
	$pageId = 1;
}else{
	$pageId = intval($pageId); 
}
$paginator = new Paginator($pageId,$recordsPerPage,$query,$conn);
$paginator->debug = FALSE;
$paginator->fields = 'name';
$paginator->searchQuery = $searchQuery;
$rows = $paginator->paginate();
?>


<html>
<head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Inbox</title>
<link href="css_paging_inbox/style.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="js_paging_inbox/ajax.js"></script>
<script type="text/javascript" src="js_paging_inbox/ajaxUpdater.js"></script> 
<script type="text/javascript" src="js_paging_inbox/paginate.js"></script>
<script language='javascript'>

checked=false;
function checkedAll (frm1) {
	var aa= document.getElementById('frm1');
	 if (checked == false)
          {
           checked = true
          }
        else
          {
          checked = false
          }
	for (var i =0; i < aa.elements.length; i++) 
	{
	 aa.elements[i].checked = checked;
	}
      }
	  
function deleteRow(rcrd){
    try {   
            var table = document.getElementById(rcrd);   
            var rowCount = table.rows.length;   
  alert(rowCount);
            for(var i=0; i<rowCount; i++) {   
                var row = table.rows[i];   
                var chkbox = row.cells[0].childNodes[0];   
                if(null != chkbox && true == chkbox.checked) {   
                    table.deleteRow(i);   
                    rowCount--;   
                    i--;   
                }   
 
            }   
            }catch(e) {   
                alert(e);   
            }
       
              
}
</script>
<style type="text/css">
<!--
.style1 {color: #666666}
-->
</style>
</head>
<body>
<div id="content" style="width:700px;">
<div id="wrapper">
<div id='search-box' class="search-box" style="padding-right:0px; padding-top:15px; border:none; margin-right:20px;">
<form action="<?=$_SERVER['PHP_SELF']?>" onsubmit='paginate();return false;'>
<?php 
echo parse_str($_SERVER['QUERY_STRING'],$getArray);
foreach($getArray as $key=>$value){
echo "<input type='hidden' name='{$key}' id='{$key}' value='{$value}' />";
}
?>
<input id="search" type="text" class="search" />
<input type="submit" value="search" class="button" />
</form>
</div>

<div id="listing_container">
<table border="0" width="91%" id="table21" height="100%" cellspacing="1" style="padding:10px">
  <tr bgcolor="#666666" height="29">
	<td colspan="8" align="left" valign="top" bgcolor="#C5D8EB"><span class="style1"></span><span class="style1"></span><span class="style1"></span><span class="style1"></span><span class="style1"></span></td>
	</tr>
  <tr>
	<td bgcolor="#E5E5E5" align="left" valign="top" width="1%">&nbsp;</td>
	<td bgcolor="#E5E5E5" align="left" valign="top" width="5%"><img border="0" src="images/my_pag2.jpg"></td>
	<td bgcolor="#E5E5E5" align="left" colspan="5"><span lang="en-us">&nbsp;</span><span lang="en-us" style="font-size:       8.5pt"><font face="Verdana" color="#006699"><b>INBOX</b></font><font color="#000000" face="Verdana"> 
	   (</font></span><font color="#000000" face="Verdana"><span style="font-size: 8.5pt"><span lang="en-us"><b>(<?php echo         $no_of_record1;?>)</b></span><span lang="en-us">Unread M</span>ails<span lang="en-us">)</span></span></font></td>
       <td bgcolor="#E5E5E5" align="left" valign="top" width="1%">&nbsp;</td>
	</tr>
  <tr>
	<td bgcolor="#E5E5E5" align="left" valign="top">&nbsp;</td>
	<td bgcolor="#E5E5E5" align="left" valign="top">&nbsp;</td>
	<td width="31%" align="left" valign="top" bgcolor="#E5E5E5"><font color="#000000" face="Verdana">
	  <span style="font-size: 8.5pt">&nbsp;Welcome to the <span lang="en-us">Inbox</span></span></font></td>
	<td width="36%" align="left" valign="top" bgcolor="#E5E5E5"><span lang="en-us">
	   <font face="Verdana" style="font-size: 8.5pt" color="#000000">	   </font></span><font color="#000000" face="Verdana"><span style="font-size: 8.5pt">&nbsp;You have messages&nbsp;<b>(<?php echo        $no_of_record;?>)</b></span></font></td>
	<td bgcolor="#E5E5E5" align="left" valign="top" width="5%"><p align="right"></td>
	<td bgcolor="#E5E5E5" align="left" valign="top" width="8%"><p align="right"></td>
	<td bgcolor="#E5E5E5" align="left" valign="top" width="13%">&nbsp;</td>
    <td bgcolor="#E5E5E5" align="left" valign="top">&nbsp;</td>
	</tr>
  
  <tr>
	<td bgcolor="#E5E5E5" align="left" valign="top">&nbsp;</td>
	<td bgcolor="#E5E5E5" align="left" valign="top">&nbsp;</td>
	<td bgcolor="#E5E5E5" align="left" valign="top" colspan="5" bordercolor="#F2F2F2"></td>
    <td bgcolor="#E5E5E5" align="left" valign="top">&nbsp;</td>
	</tr>
  <tr>
	<td bgcolor="#E5E5E5" align="left" valign="top">&nbsp;</td>
	<td bgcolor="#E5E5E5" align="left" valign="top">&nbsp;</td>
	<td align="left" valign="top" colspan="5">
	<form name="myform" action="del1.php" method="request" id="frm1">
	<table border="1" bordercolor="#003366" style="border-style:solid; border-collapse:collapse" width="97%" id="rcrd">
    <tr>
	<td width="24" height="22">&nbsp;</td>
	<td width="20" height="22">&nbsp;</td>
	<td width="32" height="22">&nbsp;</td>
	<td width="139" height="22">
	     <font color="#000000" face="Verdana">
		 <span style="font-size: 8.5pt; font-weight: 700">
		 FROM</span></font></td>
	<td width="328" height="22"> <font color="#000000" face="Verdana">
					 <span style="font-size: 8.5pt; font-weight: 700">
					  SUBJECT</span></font></td>
	<td width="60" height="22">
						<span style="font-weight: 700" lang="en-us">
						<font face="Verdana" style="font-size: 8.5pt" color="#000000">
						DATE</font></span></td>
   </tr>
         <?php
		foreach($rows as $row)
     		{
   		?>
    <tr>
		<td bgcolor="" width="24">&nbsp;</td>
		<td bgcolor="" width="20"><font style="font-size: 8.5pt" face="Verdana" color="#000000">
		<input type="checkbox" name="ids[]" value="<?php echo $row['id'];?>" /></font></td>
		<td bgcolor="" width="32">
		                                <?php 
										if($row['status']=='0')
										{?>
										<img border="0" src="images/open_mail.JPG">
										<?php }
										?>
										<?php 
										if($row['status']=='1')
										{?>
								        <img border="0" src="images/invest5.jpg">
										<?php } ?>										</td>
									    <td bgcolor="" width="139">
									      <font style="font-size: 8.5pt" face="Verdana" color="#000000">
									    <?php echo $row['sender']; ?></font></td>
									    <td bgcolor="">
										
										<font style="font-size: 8.5pt" face="Verdana" color="#000000">
										
								<a style="text-decoration:none; color:#000000" href="inbox_mail.php?id=<?php echo $row['id'];?>"><?php  echo $row['sub'];?> </a>							</font>							</td>
									    <td bgcolor="" width="60">
									      <font style="font-size: 8.5pt" face="Verdana" color="#000000">
							            	<?php 
										echo $row['post_time'];
										
										?></font></td>
			    </tr>
									  <?php
									  }
									  ?>
									   <tr>
								        <td width="24" height="22">&nbsp;</td>
									    <td width="20" height="22">&nbsp;</td>
									    <td width="32" height="22">&nbsp;</td>
									    <td height="22" colspan="2"></td>
									    <td width="60" height="22">&nbsp;</td>
									  </tr>
									  <tr>
								        <td bgcolor="#F2F2F2" width="24">&nbsp;</td>

<td bgcolor="#F2F2F2" colspan="4">&nbsp;


<input name="checkall" type="button" onclick='checkedAll(frm1);' value="Select All" style="border:1px solid #000000; font-size: 8pt; font-family: Verdana; "/>&nbsp;
<input type="submit" value="Delete Selected" name="B1" style="border:1px solid #000000; font-size: 8pt; font-family: Verdana; "/></td>
<td bgcolor="#F2F2F2" width="60">&nbsp;</td>
</tr></table></form></td>
<td bgcolor="#E5E5E5" align="left" valign="top">&nbsp;</td>
	</tr>
<tr>
				            <td bgcolor="#E5E5E5" align="left" valign="top">&nbsp;</td>
								  <td bgcolor="#E5E5E5" align="left" valign="top">&nbsp;</td>
								  <td bgcolor="#E5E5E5" align="left" valign="top" colspan="5">
								    <font color="#000000" face="Verdana">
							        <span style="font-size: 8.5pt">
							        <img border="0" src="images/invest5.jpg"> = 
						          Unread</span></font></td>
                                  <td bgcolor="#E5E5E5" align="left" valign="top">&nbsp;</td>
	    </tr>
         <tr>
            <td bgcolor="#E5E5E5" align="left" valign="top">&nbsp;</td>
								  <td bgcolor="#E5E5E5" align="left" valign="top">&nbsp;</td>
								  <td bgcolor="#E5E5E5" align="left" valign="top" colspan="5">
								    <font color="#000000" face="Verdana">
							        <span style="font-size: 8.5pt">
							        <img border="0" src="images/open_mail.JPG" width="18" height="16"> 
						          = Read</span></font></td>
                                  <td bgcolor="#E5E5E5" align="left" valign="top">&nbsp;</td>
	    </tr>
</table>	
<?php
$links = $paginator->getLinks ();
echo "<div class='paginator'> " . $links ;

echo "<p>Page " . $paginator->pageId . " of " . $paginator->totalPages . "</p>";

?>
	</div><!--end of paginator-->
	</div><!--end of listing_container-->
</div><!--end of wrapper-->
</div> <!-- end of content -->

</body>
</html>